from pathlib import Path
import os


class Settings:
    # 基础路径配置
    BASE_DIR = Path(__file__).resolve().parent.parent
    DATA_DIR = BASE_DIR / "data"
    OUTPUT_DIR = BASE_DIR / "output"
    KEY_DIR = BASE_DIR / "keys"
    LOG_DIR = BASE_DIR / "logs"

    # 确保目录存在
    for directory in [DATA_DIR, OUTPUT_DIR, KEY_DIR, LOG_DIR]:
        directory.mkdir(exist_ok=True)

    # 加密配置
    ENCRYPTION_KEY_PATH = KEY_DIR / "encryption.key"

    # 日志配置
    LOG_FILE = LOG_DIR / "data_processor.log"
    LOG_LEVEL = "INFO"  # DEBUG, INFO, WARNING, ERROR, CRITICAL

    # 性能配置
    CHUNK_SIZE = 65536  # 64KB
    MAX_FILE_SIZE = 1024 * 1024 * 1024  # 1GB

    @classmethod
    def get_db_config(cls):
        """获取数据库配置（示例）"""
        return {
            "host": os.getenv("DB_HOST", "localhost"),
            "port": int(os.getenv("DB_PORT", 5432)),
            "user": os.getenv("DB_USER", "postgres"),
            "password": os.getenv("DB_PASSWORD", ""),
            "database": os.getenv("DB_NAME", "data_quality")
        }


# 实例化配置
settings = Settings()